<?php $params = sfOutputEscaper::unescape($params) ?>

<?php if ($pager->haveToPaginate()): ?>
  <div class="pagination">

  <?php if ($pager->getPage() > 1) : ?>
    <a title="<?php echo __('Previous page') ?>" href="<?php echo url_for($route, array_merge($params, array('page' => $pager->getPreviousPage()))) ?>">
      &lt;
    </a>
  <?php endif ?>

  <?php if ($pager->getPage() > 3) : ?>
    <a href="<?php echo url_for($route, array_merge($params, array('page' => 1))) ?>">
      <?php echo $pager->getFirstPage() ?>
    </a>&nbsp;...&nbsp;
  <?php endif ?>

  <?php foreach ($pager->getLinks() as $page): ?>
    <?php if ($page == $pager->getPage()): ?>
      <span class="selected"><?php echo $page ?></span>
    <?php else: ?>
      <a href="<?php echo url_for($route, array_merge($params, array('page' => $page))) ?>"><?php echo $page ?></a>
    <?php endif ?>
  <?php endforeach ?>

  <?php if ($pager->getPage() != $pager->getLastPage() && $pager->getPage() < $pager->getLastPage() - 2) : ?>
  &nbsp;...&nbsp;
  <a href="<?php echo url_for($route, array_merge($params, array('page' => $pager->getLastPage()))) ?>">
    <?php echo $pager->getLastPage() ?>
  </a>
  <?php endif ?>

  <?php if ($pager->getPage() < $pager->getLastPage()) : ?>
    <a title="<?php echo __('Next page') ?>" href="<?php echo url_for($route, array_merge($params, array('page' => $pager->getNextPage()))) ?>">
      &gt;
    </a>
  <?php endif ?>
  </div>
<?php endif ?>